<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企业微信管理后台</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../css/reset.css">
    <link rel="stylesheet" href="../../css/fonts.css">
    <link rel="stylesheet" href="../../js/bootstrap/css/bootstrap.min.css">
    <!-- bootstrap表格 -->
    <link rel="stylesheet" href="../../js/bootstrap/js/bootstrap-table-master/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../js/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/main.css">
</head>
<!-- 联系客户统计 -->

<body>
    <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    <div id="contact_cus_kpi">
        <div class="header">
            <div class="back">返回</div>
            <div class="type_select_wrapper">客户统计概况</div>
        </div>
        <div class="container">
            <div class="group_record">
                <div class="title">联系概况</div>
                <div class="public_wrapper">
                    <span class="go_contact_cus_statis">查看成员联系客户统计</span>
                </div>
            </div>
            <div class="screen_wrapper">
                <div class="screen_tab">
                    <ul>
                        <li class="active">昨日</li>
                        <li>近七日</li>
                        <li>近30日</li>
                    </ul>
                </div>
                <div class="screen_date">
                    <span class="text">自定义：</span>
                    <input class="layui-input" type="text" id="start_date">
                    <span class="units">至</span>
                    <input class="layui-input" type="text" id="end_date">
                </div>
                <div class="member_depart">
                    <span>成员/部门：</span>
                    <div class="member_depart_select" id="member_depart_select">全部</div>
                </div>
            </div>
            <div class="tab_items">
                <div class="tab_item active">添加客户</div>
                <div class="tab_item">与客户聊天</div>
                <div class="tab_item">客户流失</div>
            </div>

            <div class="tab_section section1">
                <div class="header_wrapper">
                    <div class="item active">
                        <span class="num apply_num">0</span>
                        <span class="text">发起申请数</span>
                    </div>
                    <div class="item">
                        <span class="num add_cus_num">1</span>
                        <span class="text">新增客户数</span>
                    </div>
                </div>
                <div class="kpi_wrapper">
                    <div id="reply_kpi"></div>
                    <div id="add_cus_kpi" style="display: none;"></div>
                </div>
            </div>

            <div class="tab_section section2" style="display:none;">
                <div class="header_wrapper">
                    <div class="item active">
                        <span class="num chat_total_num">0</span>
                        <span class="text">聊天总数</span>
                    </div>
                    <div class="item">
                        <span class="num send_msg_num">0</span>
                        <span class="text">发送消息数</span>
                    </div>
                    <div class="item">
                        <span class="num reply_recent">--</span>
                        <span class="text">已回复聊天占比</span>
                    </div>
                    <div class="item">
                        <span class="num first_reply_time">0</span>
                        <span class="text">平均首次回复时长</span>
                    </div>
                </div>
                <div class="kpi_wrapper">
                    <div id="chat_total_kpi"></div>
                    <div id="send_msg_kpi" style="display: none;"></div>
                    <div id="reply_chat_recent_kpi" style="display: none;"></div>
                    <div id="first_reply_time_kpi" style="display: none;"></div>
                </div>
            </div>

            <div class="tab_section section3" style="display:none;">
                <div class="header_wrapper">
                    <div class="item active">
                        <span class="num delete_cus_num">0</span>
                        <span class="text">删除/拉黑成员的客户数</span>
                    </div>
                </div>
                <div class="kpi_wrapper">
                    <div id="delete_member_cus_kpi"></div>
                </div>
            </div>


        </div>
    </div>

    <!-- 批量修改标签、修改标签模态框 -->
    <div class="modal fade" id="cus_logo_edit_modal" tabindex="-1" role="dialog"
        aria-labelledby="cus_logo_edit_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="cus_logo_edit_modal_label">标签修改</h4>
                </div>
                <div class="modal-body">
                    <div class="msg_container">
                        <form class="layui-form">
                            <div class="layui-form-item">
                                <span class="logo_title">标签：</span>
                                <div class="layui-input-block">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="一般" value="一般">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="重要" value="重要">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="核心" value="核心">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="submit_cus_logo_edit">确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 批量修改标签、修改标签模态框 -->

    <!-- 添加人模态框 -->
    <div class="modal fade" id="addperson_modal" tabindex="-1" role="dialog" aria-labelledby="addperson_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="addperson_modal_label">选择发送范围</h4>
                </div>
                <div class="modal-body">
                    <div class="select_person_wrapper">
                        <div class="left_wrapper">
                            <div class="protree_container"></div>
                        </div>
                        <div class="right_wrapper">
                            <div class="title">已选择的部门或成员</div>
                            <div class="selected">
                                <div class="department_members selected_department" id="selected_department">

                                </div>
                                <div class="department_members selected_members" id="selected_members">

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="submit_dep_member">确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 添加人模态框 -->

    <script src="../../js/jquery-3.3.1.min.js"></script>
    <script src="../../js/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../js/layui/layui.js"></script>
    <!-- 树形结构 -->
    <script src="../../js/proTree.js"></script>
    <!-- 图表 -->
    <script src="../../js/highcharts/highcharts.js"></script>
    <script src="../../js/highcharts/exporting.js"></script>
    <script src="../../js/highcharts/no-data-to-display.js"></script>
    <!-- 公共方法 -->
    <script src="../../js/addPerson_data/data.js"></script>
    <script>
        // 2020-02-28 start
        // 指定日期的前多少天日期
        function specifiedPreDate(date, dayNum) {
            var day1 = new Date(date);
            day1.setTime(day1.getTime() - (dayNum || 1) * 24 * 60 * 60 * 1000);
            let month = "";
            let day = "";
            if (day1.getMonth() < 10) {
                month = "0" + (day1.getMonth() + 1);
            } else {
                month = day1.getMonth() + 1;
            }
            if (day1.getDate() < 10) {
                day = "0" + day1.getDate();
            } else {
                day = day1.getDate();
            }
            var s1 = day1.getFullYear() + "-" + month + "-" + day;
            return s1;
        }
        // 指定日期的后多少天日期
        function specifiedNextDate(date, dayNum) {
            var day1 = new Date(date);
            day1.setTime(day1.getTime() + (dayNum || 1) * 24 * 60 * 60 * 1000);
            let month = "";
            let day = "";
            if (day1.getMonth() < 10) {
                month = "0" + (day1.getMonth() + 1);
            } else {
                month = day1.getMonth() + 1;
            }
            if (day1.getDate() < 10) {
                day = "0" + day1.getDate();
            } else {
                day = day1.getDate();
            }
            var s1 = day1.getFullYear() + "-" + month + "-" + day;
            return s1;
        }
        // 2020-02-28 end
        var arr = [
            {
                id: 1,
                name: "长沙峰之道",
                pid: 2,
                department: true
            },
            {
                id: 2,
                name: "长沙沃邦",
                pid: 0,
                department: true
            },
            {
                id: 10,
                name: '子公司',
                pid: 1,
                department: true
            },
            {
                id: "LiuYiHua",
                name: "刘毅华",
                pid: 1,
                department: false
            },
            {
                id: "YeKaiQi",
                name: "叶铠齐",
                pid: 1,
                department: false
            },
            {
                id: "LiangXiaoLing",
                name: "梁小玲",
                pid: 1,
                department: false
            },
            {
                id: "WuFang",
                name: "吴访",
                pid: 10,
                department: false
            },
            {
                id: "ZhaoHongRui",
                name: "赵虹蕊",
                pid: 2,
                department: false
            },
            {
                id: "LvHaiYang",
                name: "吕海洋",
                pid: 2,
                department: false
            },
            {
                id: "ZengHongYun",
                name: "曾红云",
                pid: 2,
                department: false
            }
        ];
        // 2020-02-20 start
        let nav_index = getUrlParam('nav_index') // 拿到点击进来的nav_index
        // 2020-02-20 end

        layui.use('layer', function () {
            var layer = layui.layer;

            // 2020-02-20 start
            // 返回
            $(".back").click(function () {
                self.location.href = "contact-cus-kpi-1.html?nav_index=" + nav_index
            })
            // 2020-02-20 end

            // 2020-02-06 Version1.0
            // 查看成员联系客户统计
            $(".go_contact_cus_statis").click(function () {
                self.location.href = "member-contact-cus.html"
            })
            // 2020-02-06 Version1.0
            layui.use('form', function () {
                var form = layui.form;
                // 2020-02-06 Version1.0
                // 昨天的日期
                let preDate = getPreDate()
                // 前7天的日期
                let pre_7_Date = getPreDate(7)
                // 前30天的日期
                let pre_30_Date = getPreDate(30)

                // 选择的开始日期 结束日期
                let startDateSelected = preDate // 自定义开始日期
                let endDateSelected = preDate // 自定义结束日期
                layui.use('laydate', function () {
                    var laydate = layui.laydate;
                    // 2020-02-28 start
                    // 自定义开始日期
                    var startDate = laydate.render({
                        elem: '#start_date',
                        value: preDate,
                        // min: '',
                        max: preDate,
                        btns: ['clear', 'confirm'],
                        done(value, date) {
                            startDateSelected = value
                            let next_30 = specifiedNextDate(value, 30) // 拿到当前选择日期的后30天日期
                            if (next_30 > preDate) {
                                next_30 = preDate
                            }
                            endDate.config.min = {
                                year: date.year,
                                month: date.month - 1,
                                date: date.date
                            }
                            endDate.config.max = {
                                year: parseInt(next_30.split('-')[0]),
                                month: parseInt(next_30.split('-')[1]) - 1,
                                date: parseInt(next_30.split('-')[2])
                            }
                            $("#end_date").val('')
                        }
                    })

                    // 自定义结束日期
                    var endDate = laydate.render({
                        elem: '#end_date',
                        value: preDate,
                        min: preDate,
                        max: preDate,
                        btns: ['clear', 'confirm'],
                        done(value, date) {
                            endDateSelected = value
                            let pre_30 = specifiedPreDate(value, 30) // 拿到当前选择日期的前30天日期
                            startDate.config.min = {
                                year: parseInt(pre_30.split('-')[0]),
                                month: parseInt(pre_30.split('-')[1]) - 1,
                                date: parseInt(pre_30.split('-')[2])
                            }
                        }
                    })
                    // 2020-02-28 end


                    // 日期tab切换 默认进来是昨日的tab
                    let dateTabSelect = "昨日"
                    $(".screen_tab ul li").click(function () {
                        dateTabSelect = $(this).text()
                        $(this).addClass("active").siblings().removeClass("active")

                        // 2020-02-28 start
                        if (dateTabSelect == '昨日') {
                            // 自定义开始日期
                            let startDate = laydate.render({
                                elem: '#start_date',
                                value: preDate,
                                // min: '',
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    startDateSelected = value
                                    let next_30 = specifiedNextDate(value, 30) // 拿到当前选择日期的后30天日期
                                    if (next_30 > preDate) {
                                        next_30 = preDate
                                    }
                                    endDate.config.min = {
                                        year: date.year,
                                        month: date.month - 1,
                                        date: date.date
                                    }
                                    endDate.config.max = {
                                        year: parseInt(next_30.split('-')[0]),
                                        month: parseInt(next_30.split('-')[1]) - 1,
                                        date: parseInt(next_30.split('-')[2])
                                    }
                                    $("#end_date").val('')
                                }
                            })

                            // 自定义结束日期
                            let endDate = laydate.render({
                                elem: '#end_date',
                                value: preDate,
                                min: preDate,
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    endDateSelected = value
                                    let pre_30 = specifiedPreDate(value, 30) // 拿到当前选择日期的前30天日期
                                    startDate.config.min = {
                                        year: parseInt(pre_30.split('-')[0]),
                                        month: parseInt(pre_30.split('-')[1]) - 1,
                                        date: parseInt(pre_30.split('-')[2])
                                    }
                                }
                            })
                        } else if (dateTabSelect == '近七日') {
                            // 自定义开始日期
                            let startDate = laydate.render({
                                elem: '#start_date',
                                value: pre_7_Date,
                                // min: '',
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    startDateSelected = value
                                    let next_30 = specifiedNextDate(value, 30) // 拿到当前选择日期的后30天日期
                                    if (next_30 > preDate) {
                                        next_30 = preDate
                                    }
                                    endDate.config.min = {
                                        year: date.year,
                                        month: date.month - 1,
                                        date: date.date
                                    }
                                    endDate.config.max = {
                                        year: parseInt(next_30.split('-')[0]),
                                        month: parseInt(next_30.split('-')[1]) - 1,
                                        date: parseInt(next_30.split('-')[2])
                                    }
                                    $("#end_date").val('')
                                }
                            })

                            // 自定义结束日期
                            let endDate = laydate.render({
                                elem: '#end_date',
                                value: preDate,
                                min: preDate,
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    endDateSelected = value
                                    let pre_30 = specifiedPreDate(value, 30) // 拿到当前选择日期的前30天日期
                                    startDate.config.min = {
                                        year: parseInt(pre_30.split('-')[0]),
                                        month: parseInt(pre_30.split('-')[1]) - 1,
                                        date: parseInt(pre_30.split('-')[2])
                                    }
                                }
                            })
                        } else if (dateTabSelect == '近30日') {
                            // 自定义开始日期
                            let startDate = laydate.render({
                                elem: '#start_date',
                                value: pre_30_Date,
                                // min: '',
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    startDateSelected = value
                                    let next_30 = specifiedNextDate(value, 30) // 拿到当前选择日期的后30天日期
                                    if (next_30 > preDate) {
                                        next_30 = preDate
                                    }
                                    endDate.config.min = {
                                        year: date.year,
                                        month: date.month - 1,
                                        date: date.date
                                    }
                                    endDate.config.max = {
                                        year: parseInt(next_30.split('-')[0]),
                                        month: parseInt(next_30.split('-')[1]) - 1,
                                        date: parseInt(next_30.split('-')[2])
                                    }
                                    $("#end_date").val('')
                                }
                            })

                            // 自定义结束日期
                            let endDate = laydate.render({
                                elem: '#end_date',
                                value: preDate,
                                min: preDate,
                                max: preDate,
                                btns: ['clear', 'confirm'],
                                done(value, date) {
                                    endDateSelected = value
                                    let pre_30 = specifiedPreDate(value, 30) // 拿到当前选择日期的前30天日期
                                    startDate.config.min = {
                                        year: parseInt(pre_30.split('-')[0]),
                                        month: parseInt(pre_30.split('-')[1]) - 1,
                                        date: parseInt(pre_30.split('-')[2])
                                    }
                                }
                            })
                        }
                        // 2020-02-28 end
                    })
                })

                // 2020-02-06 Version1.0

                // 第二级tab切换 默认为第一个 【添加客户、与客户聊天、客户流失】
                $(".tab_items .tab_item").click(function () {
                    cusTypeTabSelect = $(this).text()
                    $(this).addClass("active").siblings().removeClass("active")
                    console.log(cusTypeTabSelect)
                    if (cusTypeTabSelect == '添加客户') {
                        $(".section1").show()
                        $(".section2").hide()
                        $(".section3").hide()
                    } else if (cusTypeTabSelect == '与客户聊天') {
                        $(".section1").hide()
                        $(".section2").show()
                        $(".section3").hide()
                    } else if (cusTypeTabSelect == '客户流失') {
                        $(".section1").hide()
                        $(".section2").hide()
                        $(".section3").show()
                    }
                })

                // 第三级tab切换 默认为第一个 【发起申请数、新增客户数等】
                // 2020-02-06 Version1.0
                $(".section1 .header_wrapper .item").click(function () {
                    $(this).addClass("active").siblings().removeClass("active")
                    let clickText = $(this).find('.text').text()
                    if (clickText == '发起申请数') {
                        $("#reply_kpi").show()
                        $("#add_cus_kpi").hide()
                    } else if (clickText == '新增客户数') {
                        $("#reply_kpi").hide()
                        $("#add_cus_kpi").show()
                    }
                })

                $(".section2 .header_wrapper .item").click(function () {
                    $(this).addClass("active").siblings().removeClass("active")
                    let clickText = $(this).find('.text').text()
                    if (clickText == '聊天总数') {
                        $("#chat_total_kpi").show()
                        $("#send_msg_kpi").hide()
                        $("#reply_chat_recent_kpi").hide()
                        $("#first_reply_time_kpi").hide()
                    } else if (clickText == '发送消息数') {
                        $("#chat_total_kpi").hide()
                        $("#send_msg_kpi").show()
                        $("#reply_chat_recent_kpi").hide()
                        $("#first_reply_time_kpi").hide()
                    } else if (clickText == '已回复聊天占比') {
                        $("#chat_total_kpi").hide()
                        $("#send_msg_kpi").hide()
                        $("#reply_chat_recent_kpi").show()
                        $("#first_reply_time_kpi").hide()
                    } else if (clickText == '平均首次回复时长') {
                        $("#chat_total_kpi").hide()
                        $("#send_msg_kpi").hide()
                        $("#reply_chat_recent_kpi").hide()
                        $("#first_reply_time_kpi").show()
                    }
                })
                // 2020-02-06 Version1.0

                // 客户流失中只有【删除/拉黑成员的客户数】 所以这里不做切换之后的事件处理 默认加载第一个就行了

                // 2020-02-28 start
                let depSelected = []; // 选择的部门
                let memberSelected = []; // 选择的成员
                let totalDatalist = []; // 部门、成员总集合
                // 点击 成员部门 打开添加模态框 且 重新加载已选择的成员
                $("#member_depart_select").click(function () {
                    $("#addperson_modal").modal("show");
                    let html1 = "";
                    let html2 = "";
                    for (let i = 0; i < depSelected.length; i++) {
                        html1 += `
                        <div class="dep_item">
                            <i class="iconfont icon-wenjianjia"></i>
                            <span data-id="${depSelected[i].id}" data-pid="${depSelected[i].pid}" data-dep="${depSelected[i].department}" data-useful="${depSelected[i].Useful}">${depSelected[i].name}</span>
                            <i class="iconfont icon-shanchu delete_dep_mem"></i>
                        </div>
                        `;
                    }
                    for (let j = 0; j < memberSelected.length; j++) {
                        html2 += `
                        <div class="mem_item">
                            <i class="iconfont icon-geren"></i>
                            <span data-id="${memberSelected[j].id}" data-pid="${memberSelected[j].pid}" data-dep="${memberSelected[j].department}" data-useful="${memberSelected[j].Useful}">${memberSelected[j].name}</span>
                            <i class="iconfont icon-shanchu delete_dep_mem"></i>
                        </div>
                        `;
                    }
                    $("#selected_department").html(html1);
                    $("#selected_members").html(html2);
                });

                //标题的图标是集成bootstrap 的图标  更改 请参考bootstrap的字体图标替换自己想要的图标
                $(".protree_container").ProTree({
                    arr: arr,
                    close: true,
                    simIcon: "iconfont icon-geren", //单个标题字体图标 不传默认glyphicon-file
                    mouIconOpen: "iconfont icon-wenjianjia1", //含多个标题的打开字体图标  不传默认glyphicon-folder-open
                    mouIconClose: "iconfont icon-wenjianjia", //含多个标题的关闭的字体图标  不传默认glyphicon-folder-close
                    callback: function (id, name, pid, department, useful) {
                        let data = {
                            id,
                            name,
                            pid: parseInt(pid),
                            department,
                            Useful: useful
                        };
                        if (department == true || department == 'true') {
                            data.id = parseInt(id)
                            data.department = true
                        } else if (department == 'false') {
                            data.department = false
                        }
                        if (useful == 'true') {
                            data.Useful = true
                        } else {
                            data.Useful = false
                        }
                        console.log('data', data);
                        if (data.department) {
                            depSelected.push(data);
                            $("#selected_department").append(`
                        <div class="dep_item">
                            <i class="iconfont icon-wenjianjia"></i>
                            <span data-id="${data.id}" data-pid="${data.pid}" data-dep="${data.department}" data-useful="${data.Useful}">${data.name}</span>
                            <i class="iconfont icon-shanchu delete_dep_mem"></i>
                        </div>
                        `);
                        } else {
                            memberSelected.push(data);
                            $("#selected_members").append(`
                        <div class="mem_item">
                            <i class="iconfont icon-geren"></i>
                            <span data-id="${data.id}" data-pid="${data.pid}" data-dep="${data.department}" data-useful="${data.Useful}">${data.name}</span>
                            <i class="iconfont icon-shanchu delete_dep_mem"></i>
                        </div>
                        `);
                        }
                    }
                });

                // 删除部门、成员
                $(".department_members").on("click", ".delete_dep_mem", function () {
                    let id = $(this)
                        .siblings("span")
                        .attr("data-id");
                    let dep = $(this)
                        .siblings("span")
                        .attr("data-dep");
                    $(this)
                        .parent()
                        .remove();
                    if (dep) {
                        for (let i = 0; i < depSelected.length; i++) {
                            if (id == depSelected[i].id) {
                                depSelected.splice(i, 1);
                                break;
                            }
                        }
                    } else {
                        for (let i = 0; i < memberSelected.length; i++) {
                            if (id == memberSelected[i].id) {
                                memberSelected.splice(i, 1);
                                break;
                            }
                        }
                    }
                });
                function getMember(depMember, depList) {
                    if (depList && depList.length > 0) {
                        for (let i = 0; i < depList.length; i++) {
                            if (depList[i].department == true || depList[i].department == 'true') {
                                let m = []
                                for (let j = 0; j < arr.length; j++) {
                                    if (arr[j].pid == depList[i].id) {
                                        m.push(arr[j])
                                    }
                                }
                                getMember(depMember, m)
                            } else if (depList[i].department == false || depList[i].department == 'false') {
                                if (depList[i].Useful) {
                                    depMember.push(depList[i])
                                }
                            }
                        }
                    }
                }

                // 拿到需要发送的部门、成员列表
                $("#submit_dep_member").click(function () {
                    totalDatalist = [];
                    totalDatalist = totalDatalist.concat(depSelected, memberSelected); // 选择的部门、成员
                    let member_depart_select = ""
                    for (let i = 0; i < totalDatalist.length; i++) {
                        member_depart_select += `${totalDatalist[i].name},`
                    }
                    member_depart_select = member_depart_select.substring(0, member_depart_select.length - 1)
                    console.log(member_depart_select)
                    if (member_depart_select == '') {
                        $("#member_depart_select").text('全部')
                    } else {
                        $("#member_depart_select").text(member_depart_select)
                        $("#member_depart_select").attr('title', member_depart_select)
                    }

                    console.log('totalDatalist', totalDatalist)
                    // 取出选中的部门中的所有成员
                    let depMember = []
                    getMember(depMember, totalDatalist) // 将选择的部门中的成员取出来

                    // 成员去重
                    for (var i = 0; i < depMember.length; i++) {
                        for (var j = i + 1; j < depMember.length; j++) {
                            if (depMember[i].id == depMember[j].id) {
                                depMember.splice(j, 1);
                            }
                        }
                    }
                    console.log(
                        "添加人",
                        depMember
                    );
                    $("#addperson_modal").modal("hide");
                });

                // 2020-02-28 end
            })

        })


        // 表格分页
        layui.use('laypage', function () {
            var laypage = layui.laypage;
            // 【有标签客户】
            laypage.render({
                elem: 'paging',
                limit: 5,
                theme: '#E51C23',
                count: 20, //数据总数，从服务端得到
                jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    //首次不执行
                    if (!first) {
                        //do something
                    }
                }
            })

            // 【无标签客户】
            laypage.render({
                elem: 'n_paging',
                limit: 5,
                theme: '#E51C23',
                count: 20, //数据总数，从服务端得到
                jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    //首次不执行
                    if (!first) {
                        //do something
                    }
                }
            })
        });


        // 2020-02-06 Version1.0
        // reply_kpi 发起申请数
        var reply_kpi = Highcharts.chart('reply_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            tooltip: {
                formatter: function () {
                    var s = this.x + '<br/>';
                    $.each(this.points, function (i) {
                        if (i == 0) {
                            s += '<br/><span style="font-size: 15px;color: #000;">' + this.series.name + ': ' +
                                this.y + '</span>';
                        } else {
                            s += '<br/><span style="font-size: 13px;color: #888;margin-top: 5px;">' + this.series.name + ': ' +
                                this.y + '</span>';
                        }

                    });
                    return s;
                },
                shared: true
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '发起申请数',
                data: [0, 2, 3, 4, 5, 0, 0, 0]
            }, {
                name: '总数',
                data: [1, 2, 3, 4, 5, 6, 7, 8],
                marker: {
                    symbol: 'circle',
                    radius: 2
                },
                opacity: 0,
                color: '#ffffff'
            }]
        })

        // add_cus_kpi 新增客户数
        var add_cus_kpi = Highcharts.chart('add_cus_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '新增客户数',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })

        // chat_total_kpi 聊天总数
        var chat_total_kpi = Highcharts.chart('chat_total_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '聊天总数',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })

        // send_msg_kpi 发送消息数
        var send_msg_kpi = Highcharts.chart('send_msg_kpi', {
            title: {
                text: ''
            },
            subtitle: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '发送消息数',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })

        // reply_chat_recent_kpi 已回复聊天占比
        var reply_chat_recent_kpi = Highcharts.chart('reply_chat_recent_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '已回复聊天占比',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })

        // first_reply_time_kpi 平均首次回复时长
        var first_reply_time_kpi = Highcharts.chart('first_reply_time_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '平均首次回复时长',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })

        // delete_member_cus_kpi 删除/拉黑成员的客户数
        var delete_member_cus_kpi = Highcharts.chart('delete_member_cus_kpi', {
            title: {
                text: ''
            },
            exporting: {
                enabled: false
            },
            credits: {
                enabled: false
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: ['1-30', '1-31', '2-1', '2-2', '2-3', '2-4', '2-5', '2-6', '2-7']
            },
            yAxis: {
                title: {
                    text: ''
                }
            },
            plotOptions: {
                series: {
                    label: {
                        connectorAllowed: false
                    },
                }
            },
            series: [{
                name: '删除/拉黑成员的客户数',
                data: [0, 0, 0, 0, 0, 0, 0, 0]
            }]
        })
        // 2020-02-06 Version1.0
    </script>
</body>

</html>